// To parse this JSON data, do
//
//     final linkModel = linkModelFromJson(jsonString);
import 'dart:convert';

LinkModel linkModelFromJson(String str) => LinkModel.fromJson(json.decode(str));

String linkModelToJson(LinkModel data) => json.encode(data.toJson());

class LinkModel {
  final String linkId;
  final String link;
  final String? title;
  final String icon;
  final DateTime createAt;
  final DateTime updateAt;
  final String createdBy;
  final String active;

  LinkModel({
    required this.linkId,
    required this.link,
    required this.title,
    required this.icon,
    required this.createAt,
    required this.updateAt,
    required this.createdBy,
    required this.active,
  });

  LinkModel copyWith({
    String? linkId,
    String? link,
    dynamic title,
    String? icon,
    DateTime? createAt,
    DateTime? updateAt,
    String? createdBy,
    String? active,
  }) =>
      LinkModel(
        linkId: linkId ?? this.linkId,
        link: link ?? this.link,
        title: title ?? this.title,
        icon: icon ?? this.icon,
        createAt: createAt ?? this.createAt,
        updateAt: updateAt ?? this.updateAt,
        createdBy: createdBy ?? this.createdBy,
        active: active ?? this.active,
      );

  factory LinkModel.fromJson(Map<String, dynamic> json) => LinkModel(
    linkId: json["link_id"],
    link: json["link"],
    title: json["title"],
    icon: json["icon"],
    createAt: DateTime.parse(json["create_at"]),
    updateAt: DateTime.parse(json["update_at"]),
    createdBy: json["created_by"],
    active: json["active"],
  );

  Map<String, dynamic> toJson() => {
    "link_id": linkId,
    "link": link,
    "title": title,
    "icon": icon,
    "create_at": createAt.toIso8601String(),
    "update_at": updateAt.toIso8601String(),
    "created_by": createdBy,
    "active": active,
  };
}
